//
//  WBVisitorView.swift
//  传智微博
//
//  Created by 董涛 on 2017/6/6.
//  Copyright © 2017年 江汉油田. All rights reserved.
//

import UIKit
///访客视图
class WBVisitorView: UIView {

    override init(frame: CGRect) {
        super.init(frame: frame)
        setupUI()
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    // MARK: - 私有控件
    ///图像视图
     lazy var iconView: UIImageView = UIImageView(image:UIImage(named:"visitordiscover_feed_image_smallicon"))
    ///小房子
     lazy var houseView: UIImageView = UIImageView(image:UIImage(named:"visitordiscover_feed_image_house"))
    ///提示标签
     lazy var tipLabel: UILabel = UILabel.cz_label(withText: "关注一些人，回这里看看有什么惊喜，关注一些人，回这里看看有什么惊喜", fontSize: 16, color: UIColor.darkGray)
    ///注册按钮
     lazy var registerButto: UIButton = UIButton.cz_textButton("注册", fontSize: 16, normalColor: UIColor.orange, highlightedColor: UIColor.black, backgroundImageName: "common_button_white_disable")
    ///登录按钮
    lazy var loginButto: UIButton = UIButton.cz_textButton("注册", fontSize: 16, normalColor: UIColor.darkGray, highlightedColor: UIColor.black, backgroundImageName: "common_button_white_disable")

}
//MARK: - 设置界面
extension WBVisitorView {
    func setupUI() {
        backgroundColor = UIColor.white
        
        //添加控件
       addSubview(iconView)
        addSubview(houseView)
        addSubview(tipLabel)
        addSubview(registerButto)
        addSubview(loginButto)
        
        //2.取消 autoresizing
        for v in subviews {
            v.translatesAutoresizingMaskIntoConstraints = false
        }
        //3.自动布局
                    //图像视图
        addConstraint(NSLayoutConstraint(item: iconView,
                                         attribute: .centerX,
                                         relatedBy: .equal,
                                         toItem: self,
                                         attribute: .centerX,
                                         multiplier: 1.0, constant: 0))
        addConstraint(NSLayoutConstraint(item: iconView,
                                         attribute: .centerY,
                                         relatedBy: .equal,
                                         toItem: self,
                                         attribute: .centerY,
                                         multiplier: 1.0, constant: -60))
        
                      //小房子
        addConstraint(NSLayoutConstraint(item: houseView,
                                         attribute: .centerX,
                                         relatedBy: .equal,
                                         toItem: iconView,
                                         attribute: .centerX,
                                         multiplier: 1.0, constant: 0))
        addConstraint(NSLayoutConstraint(item: houseView,
                                         attribute: .centerY,
                                         relatedBy: .equal,
                                         toItem: iconView,
                                         attribute: .centerY,
                                         multiplier: 1.0, constant: 0))
    }
}


